package leetcode.code1732;

public class Solution {
//	输入：gain = [-5,1,5,0,-7]
//	输出：1
//	解释：海拔高度依次为 [0,-5,-4,1,1,-6] 。最高海拔为 1
	public int largestAltitude(int[] gain) {
		int ans = 0;
		for (int i = 0, h = 0; i < gain.length; i++) {
			ans = Math.max(ans, h += gain[i]);
		}
		return ans;
	}
}
